import { Component, OnInit } from '@angular/core';
import { ActivatedRoute,Params } from '@angular/router';
import { NavController } from '@ionic/angular';

@Component({
  selector: 'app-time-aty',
  templateUrl: './time-aty.page.html',
  styleUrls: ['./time-aty.page.scss'],
})
export class TimeAtyPage implements OnInit {
  type:boolean=true;
  buttonStr:string='马上抢';
  tosatStr:string='已抢3件'
  titleStr:string='限时抢购'
  menuList:any=[
    {id:'m1',value:'热门',select:true},
    {id:'m2',value:'女装',select:false},
    {id:'m3',value:'食品',select:false},
    {id:'m4',value:'水果',select:false},
    {id:'m5',value:'鞋包',select:false},
    {id:'m6',value:'百货',select:false},
    {id:'m7',value:'母婴',select:false},
    {id:'m8',value:'鞋包1',select:false},
    {id:'m9',value:'百货2',select:false},
  ] ;//菜单列表
  constructor( private activeRoute: ActivatedRoute,private nav:NavController) {
      console.log(nav);
    this.activeRoute.queryParams.subscribe((params: Params) => {
      if (params.type=='1') {
        this.type=true;
        this.buttonStr='马上抢';
        this.tosatStr='已抢3件';
        this.titleStr='限时抢购'
      }else{
        this.type=false;
        this.buttonStr='去拼团';
        this.tosatStr='已团3件';
        this.titleStr='限时团购'
      }
    });
   }

  ngOnInit() {
  }
  segmentChanged(event){
    console.log(event);
    this.menuList.forEach((element,index) => {
      console.log(event.detail.value+'===',element.id);
        if (event.detail.value==element.id) {
          this.menuList[index].select=true;
        }else{
          this.menuList[index].select=false;
        }
    });
    console.log(this.menuList);
  }
}
